package com.qianniu.napi.admin.web;


import com.baomidou.mybatisplus.plugins.Page;
import com.qianniu.napi.admin.entity.Category;
import com.qianniu.napi.admin.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author chenxuebin
 * @since 2017-11-10
 */
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private ICategoryService categoryService;


    @RequestMapping("/list/{pid}")
    @ResponseBody
    public Page<Category> list(@PathVariable("pid") int pid) {

        Page<Category> page = new Page<Category>(0, 5);
        Map<String, Object> condition = new HashMap<String, Object>();
        condition.put("pid", pid);

        page.setCondition(condition);
        Page<Category> list = categoryService.selectCatePage(page, pid);
        return list;

    }

}
